import os

import django
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application

from channels.auth import AuthMiddlewareStack
import r0monitor.routing

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'r0Blog.settings')
django.setup()
django_application = get_asgi_application()

application = ProtocolTypeRouter({
    "http": get_asgi_application(),
    "websocket": AuthMiddlewareStack(
        URLRouter(
            r0monitor.routing.websocket_urlpatterns
        )
    ),
})
